import java.util.Scanner;
import java.util.Stack;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();

        Stack<Integer> stack = new Stack<>();
        boolean preSignWell = false;
        int num = 0;

        // 在字符串末尾加一个空格，用于处理最后一个数字的情况
        s += " ";

        for (char ch : s.toCharArray()) {
            if (Character.isDigit(ch)) {
                // 将这个转换成数字
                num = num * 10 + Character.getNumericValue(ch);
            } else {
                // 如果不是数字， 这里的话， 直接放到栈中去
                stack.push(num);
                num = 0;
                if (preSignWell) {
                    int y = stack.pop();
                    int x = stack.pop();
                    // #号
                    int res = calWell(x, y);
                    stack.push(res);
                }
                preSignWell = (ch == '#');
            }
        }

        int ans = stack.get(0);
        for (int i = 1; i < stack.size(); i++) {
            int y = stack.get(i);
            // $
            ans = calDollar(ans, y);
        }

        System.out.println(ans);
    }

    private static int calWell(int x, int y) {
        return 4 * x + 3 * y + 2;
    }

    private static int calDollar(int x, int y) {
        return 2 * x + y + 3;
    }
}
